<!--  -->
<template>
  <div class="home-container">
    <van-nav-bar class="page-nav-bar">
      <van-button class="search-btn" slot="title" type="info" size="small" round icon="search">搜索</van-button>
    </van-nav-bar>
    <van-tabs v-model="active" swipeable animated>
      <van-tab :title="v.name" :key="v.id" v-for="v in Channelist">
        <article-list :channelist="v"></article-list>
      </van-tab>
      <div slot="nav-right" class="hamburger-btn" @click="isChennelEditShow = true">
        <i class="iconfont icongengduo"></i>
      </div>
    </van-tabs>

    <!-- 频道编辑弹出层 -->
    <van-popup
      v-model="isChennelEditShow"
      closeable
      close-icon-position="top-left"
      position="bottom"
      :style="{ height: '100%' }"
    >
      <!-- <channel-edit :my-channels="channels" :active="active" @update-active="onUpdateActive"/> -->
      <channel-edit :mychannels="Channelist"/>
    </van-popup>
    <!-- /频道编辑弹出层 -->
  </div>
</template>

<script>
import { getuserChannel } from '@/api/user'
import ArticleList from '@/components/article-list.vue'
import ChannelEdit from '@/components/channel-edit.vue'
export default {
  data() {
    return {
      active: 0,
      Channelist: {},
      isChennelEditShow: false // 控制编辑频道弹出层的显示状态
    }
  },
  components: {
    ArticleList,
    ChannelEdit
  },
  //生命周期 - 创建完成（访问当前this实例）
  created() {
    this.loaduserChanne()
  },
  //生命周期 - 挂载完成（访问DOM元素）
  mounted() {},
  methods: {
    loaduserChanne() {
      getuserChannel.loaduserChanne().then(data => {
        console.log(data)
        this.Channelist = data.data.channels
      })
    }
  }
}
</script>
<style scoped lang="less">
/* @import url(); 引入css类 */
.page-nav-bar {
  background-color: #1989fa;
}
.search-btn {
  width: 250px;
  height: 32px;
  background-color: #5babfb;
  border: none;
  font-size: 14px;
}
/deep/.van-nav-bar__title {
  max-width: unset;
}
.van-nav-bar .van-icon {
  color: #fff;
}
/deep/.van-tab {
  border-right: 1px solid #edeff3;
}
/deep/.van-tabs__line {
  background-color: #3296fa;
  width: 40px !important;
}
.hamburger-btn {
  position: fixed;
  right: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 33px;
  height: 41px;
  background-color: #fff;
  background-color: rgba(255, 255, 255, 0.902);
  i.iconfont {
    font-size: 15px;
  }
  &:before {
    content: '';
    position: absolute;
    left: 0;
    width: 1px;
    height: 28px;
    background-size: contain;
  }
}
</style>